package com.cloud.salon.client.menber.controller;

import com.cloud.salon.client.menber.service.StaffService;
import com.cloud.salon.common.base.response.Res;
import com.cloud.salon.common.base.entity.menber.Staff;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 员工管理控制器
 * @Author wolf--LZH
 * @CreateDate 2019/4/10 0010 下午 1:30
 */
@RestController
@RequestMapping("staff")
@Api(tags = "员工信息相关接口")
public class StaffController {

    private final String name = "员工信息";

    @Autowired
    private StaffService service;

    @PostMapping("findById")
    @ApiOperation(value="通过id查找一个" + name)
    public Res<Staff> findById(@RequestBody Integer id) {
        return service.findById(id);
    }

    @PostMapping("findByUser")
    @ApiOperation(value="通过员工账号获取对应的" + name)
    public Res<Staff> findByUser(@RequestBody Integer userId) {
        return service.findByUser(userId);
    }

    @PostMapping("findByKey")
    @ApiOperation(value="通过员工关键信息获取对应的" + name)
    public Res<List<Staff>> findByKey(@RequestBody String key) {
        return service.findByKey(key);
    }

    @PostMapping("findAll")
    @ApiOperation(value="获取所有的" + name)
    public Res<List<Staff>> findAll() {
        return service.findAll();
    }

    @PostMapping("save")
    @ApiOperation(value="添加一个" + name)
    public Res<Staff> save(@RequestBody Staff staff) {
        return service.save(staff);
    }

    @PostMapping("saveAll")
    @ApiOperation(value="批量添加" + name)
    public Res<List<Staff>> saveAll(@RequestBody List<Staff> staffs) {
        return service.saveAll(staffs);
    }

    @PostMapping("update")
    @ApiOperation(value="修改" + name + "数据")
    public Res<Staff> update(@RequestBody Staff staff) {
        return service.update(staff);
    }

    @PostMapping("updateAll")
    @ApiOperation(value="批量修改" + name + "数据")
    public Res<List<Staff>> updateAll(@RequestBody List<Staff> staffs) {
        return service.updateAll(staffs);
    }

    @PostMapping("deleteById")
    @ApiOperation(value="通过id删除对应" + name)
    public Res<Boolean> deleteById(@RequestBody Integer id) {
        return  service.deleteById(id);
    }

    @PostMapping("deleteByIdAll")
    @ApiOperation(value="通过id集合批量删除" + name)
    public Res<Integer> deleteByIdAll(@RequestBody List<Integer> ids) {
        return service.deleteByIdAll(ids);
    }
}
